<template>
  <card :header="false">
    <template v-slot:filter>
      <el-form ref="searchForm" :inline="true" :model="searchForm">
        <el-form-item label="模板名称" prop="templatename">
          <el-input
            v-model.trim="searchForm.templatename"
            placeholder="请输入模板名称"
            clearable
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="searchSubmit">查询</el-button>
        </el-form-item>
      </el-form>
    </template>
    <el-table
      ref="table"
      :data="list"
      tooltip-effect="dark"
      style="width: 100%"
      :header-cell-style="{background:'#F5F4F7'}"
      border
      stripe
      highlight-current-row
      :height="tableHeight"
    >
      <el-table-column
        type="index"
        width="60"
        align="center"
        label="序号"
        sortable
      />
      <el-table-column
        prop="strreportname"
        label="单据模板"
        min-width="220"
      />
      <el-table-column
        prop="updatedtime"
        label="修改日期"
        width="200"
      />
      <el-table-column label="操作" align="center" width="160" class-name="mb0">
        <template slot-scope="scope">
          <el-button type="text"><a :href="baseurl+':31003/ureport/designer?_u=file:'+scope.row.lngproductid+'_'+scope.row.strreportname+'.ureport.xml'" target="_blank">设计</a></el-button>
          <el-button type="text"><a :href="baseurl+':31003/ureport/preview?_u=file:'+scope.row.lngproductid+'_'+scope.row.strreportname+'.ureport.xml'" target="_blank">预览</a></el-button>
          <el-button type="text" @click="deleteEvent(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </card>
</template>
<script>
import { queryTableList, deleteRow } from '@/api/system/print-setting/print-template'
import calculateCommonTableHeight from '@/layout/mixin/calculateCommonTableHeight'
export default {
  mixins: [calculateCommonTableHeight],
  data() {
    return {
      list: [],
      searchForm: {
        templatename: ''
      },
      baseurl: this.baseurl
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      queryTableList({
        'lngproductid': 315, // 预算313
        'templatename': this.searchForm.templatename
      }).then(res => {
        if (res.code === 20000) {
          this.list = res.data
        } else {
          this.list = []
        }
      })
    },
    searchSubmit() {
      this.getList()
    },
    deleteEvent(row) {
      this.$confirm('此操作将永久删除, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        deleteRow(row.lngreportsetid).then(res => {
          if (res.code === 20000) {
            this.$message({
              type: 'success',
              message: '删除成功!'
            })
            this.getList()
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    }
  }
}
</script>
<style scoped>

</style>

